
Ext.define('ZO0.view.shipping.USPSZone', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.uspszone',

    title: 'Zones',
    store: 'shipping.USPSZone',

    frame: true,
    columnLines: true,
    selType: 'cellmodel',

    initComponent: function() {
        var me = this;

        me.afterEdit = function() {
            var cell = me.getView().getSelectionModel().getSelection()[0];
            cell.commit();
	};
        me.editing = Ext.create('Ext.grid.plugin.CellEditing');
	me.editing.addListener('afteredit', me.afterEdit);

        Ext.applyIf(me, {
            height: 400,
            plugins: [me.editing],
            viewConfig: { stripeRows: true },
            columns: [
                {
                    xtype: 'gridcolumn', header: 'Country ID', dataIndex: 'countryID', width: 70, align: 'center', locked: true
                }, {
                    xtype: 'gridcolumn', header: 'Description', dataIndex: 'description', width: 270, align: 'right', sortable: true,
                    editor: { xtype: 'textfield', allowBlank: false }
                }, {
                    xtype: 'gridcolumn', header: 'Zone ID', dataIndex: 'zoneID', width: 70, align: 'center', sortable: false, menuDisabled: true,
                    editor: { xtype: 'textfield', allowBlank: false }
                }, {
                    xtype: 'gridcolumn', header: 'Max Weight', dataIndex: 'maxweight', width: 70, align: 'center', sortable: false, menuDisabled: true,
                    editor: { xtype: 'textfield', allowBlank: false }
                }
            ],
            dockedItems: [{
                xtype: 'pagingtoolbar',
                store: 'shipping.USPSZone',
                dock: 'bottom',
                width: 360,
                displayInfo: true
            }],
            listeners: {
                render: function(grid) {
                    grid.getStore().load();
                }
            }

        });
        me.callParent(arguments);
    }
});
